<template>
	<view class="ordercontent">
		<navBar title="订单详情"></navBar>
		<view class="storeName flex_center" @click="$native.toStore(order.store_id)">
			<text>{{order.store_name || ''}}</text>
			<u-icon name="arrow-right" color="#CCCCCC" size="16"></u-icon>
		</view>

		<view class="product flex_center" @click="$native.toProduct(order.store_id , order.goods_id)">
			<image v-if="order.goods_image" :src="order.goods_image[0]" mode="aspectFill"></image>
			<view class="name hidden">
				<text>{{order.name || ''}}</text>
				<view>
					<i>￥</i>{{order.price}}
				</view>
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>实付款</text>
			<view class="price">
				<view><i>￥</i>{{order.pay_price || '0'}}</view>
			</view>
		</view>
		<!-- 购物卡 -->
		<!-- <view class="order_content_text flex_r_between" v-if="order.status != 1">
			<text>购物卡消费</text>
			<view class="price">
				<view><i>￥</i>{{order.card_price || '0.00'}}</view>
			</view>
		</view> -->

		<!-- <view class="order_content_text flex_r_between" v-if="order.kefu == 1 && (order.status == 5 || order.status == 6)">
			<text>路费</text>
			<view class="price">
				<view><i>￥</i> {{ order.fare_price }}</view>
			</view>
		</view> -->

		<!-- 2477 [创建订单]非按摩订单，商家接单后显示了客服，且收货时间不对 -->
		<!-- <view class="order_content_text flex_r_between" v-if="order.kefu == 1">
			<text>服务人员</text>
			<view class="kefu hidden">{{order.provider_nickname || '-'}}</view>
		</view> -->

		<view class="line"></view>

		<view class="order_content_text flex_r_between">
			<text>收货人：</text>
			<view class="hidden">{{order.real_name || ''}}</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>联系方式：</text>
			<view class="hidden">{{order.mobile || ''}}</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>收货地址：</text>
			<view>{{order.city || ''}}{{order.area || ''}}{{order.address || ''}}</view>
		</view>

		<view class="line"></view>

		<view class="order_content_text flex_r_between">
			<text>下单时间：</text>
			<view class="hidden">
				<uni-dateformat :date="order.create_time" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>付款时间：</text>
			<view class="hidden" v-if="order.pay_time">
				<uni-dateformat :date="order.pay_time" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
			</view>
			<view class="hidden" v-else>
				-
			</view>
		</view>
		
		<view class="order_content_text flex_r_between" v-if="order.subscribe_time">
			<text>预约时间</text>
			<view class="price">
				<view>{{order.subscribe_time || '-'}}</view>
			</view>
		</view>

		<!-- 2477 [创建订单]非按摩订单，商家接单后显示了客服，且收货时间不对 -->
		<view class="order_content_text flex_r_between">
			<text>收货时间：</text>
			<view class="hidden" v-if="order.finish_time">
				<uni-dateformat :date="order.finish_time" format="yyyy-MM-dd hh:mm:ss"></uni-dateformat>
			</view>
			<view class="hidden" v-else>
				-
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>快递单号：</text>
			<view class="hidden tracking_number" @click="onCopy(order.tracking_number)">
				<u-icon name="file-text" size="32rpx" v-if="order.tracking_number"></u-icon>
				<text>{{order.tracking_number || '-'}}</text>
			</view>
		</view>

		<view class="order_content_text flex_r_between">
			<text>订单编号：</text>
			<view class="hidden">
				{{order.order_sn || '-'}}
			</view>
		</view>

		<!-- use_card=1:余额全款，2：余额+微信，3：余额+支付宝，4=微信，5=支付宝 -->
		<view class="order_content_text flex_r_between">
			<text>支付方式：</text>
			<view class="hidden">
				{{
					order.use_card == 1 ? '余额支付'
					:order.use_card == 2 ? '组合支付(余额+微信)'
					:order.use_card == 3 ? '组合支付(余额+支付宝)'
					:order.use_card == 4 ? '微信支付'
					:order.use_card == 5 ? '支付宝支付'
					: ''
				}}
			</view>
		</view>

		<view class="order_content_text flex_r_between" v-if="order.kefu != 1">
			<text>备注：</text>
			<view>
				{{order.remark || '-'}}
			</view>
		</view>

		<view class="line"></view>

		<!-- 投诉 -->
		<view class="complant" v-if="order.complain_status == 2 || order.complain_status == 3">
			<view class="complant_title">投诉内容</view>
			<view class="complant_content">{{order.complain_info.content || ''}}</view>
			<image @click="previewImage" v-if="order.complain_info.images" :src="order.complain_info.images"
				mode="aspectFill"></image>
			<view class="complant_return" v-if="order.complain_info.check_content">
				处理结果:{{order.complain_info.check_content}}</view>
		</view>

		<!-- 拨打电话按钮 -->
		<view class="btn flex_r_around" @click="makeCall"
			v-if="order.status != null && order.status != 5 && order.status != 6 && order.status != 7">
			<view class="flex_center">
				<image src="/static/store/dianhua.png" mode=""></image>
				<text>立即联系</text>
			</view>
		</view>

	</view>
</template>

<script>
	import navBar from '@//compentents/navBar/navBar.vue';
	export default {
		components: {
			navBar,
		},
		data() {
			return {
				order_id: 0,

				order: {},
			}
		},
		methods: {
			getDetail() {
				this.$get('/order/getOrderInfo', {
					order_id: this.order_id
				}).then(res => {
					this.order = res.data;
				})
			},

			previewImage() {
				uni.previewImage({
					current: 0,
					urls: [this.order.complain_info.images],
				})

			},

			makeCall() {
				this.$native.makeCall(this.order.mobile);
			},
			
			onCopy(str) {
				if(!str){
					return;
				}
				uni.setClipboardData({
					data: `${str}`,
					showToast: false,
					success: () => {
						this.$util.msg('已复制到剪贴板');
					}
				});
			},
			
		},

		onLoad(option) {
			if (option.id) {
				this.order_id = option.id;
				this.getDetail()
			}
		}
	}
</script>

<style lang="less" scoped>
	.ordercontent {
		padding: 32rpx;
		min-height: 100vh;
		background: #FFFFFF;
	}

	// 商品
	.product {
		margin-top: 32rpx;

		image {
			width: 128rpx;
			height: 128rpx;
			border-radius: 16rpx;
			color: #ECECF4;
			margin-right: 20rpx;
		}

		.name {
			flex: 1;

			text {
				font-weight: 500;
				font-size: 32rpx;
				color: #131313;
			}

			view {
				i {
					font-size: 24rpx;
					font-style: normal;
				}

				font-weight: 600;
				font-size: 32rpx;
				color: #131313;
			}
		}

	}

	// 商品详情标签
	.line {
		height: 2rpx;
		background: #EEEEEE;
		margin-top: 32rpx;
	}

	.order_content_text {
		margin-top: 32rpx;

		text {
			font-size: 28rpx;
			color: #131313;
			width: 240rpx;
		}

		.price {
			font-weight: 600;
			font-size: 40rpx;
			color: #FD2A53;

			i {
				font-style: normal;
				font-size: 28rpx;
			}
		}

		.kefu {
			font-size: 28rpx;
			color: #999999;
		}

		view {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #999999;

			text {
				font-size: 28rpx;
				color: #999999;
			}
		}
	}

	.tracking_number {
		display: flex;
		flex-direction: row-reverse;
		align-items: center;
		view {
			flex: 0;
		}
	}

	.complant {
		background: #F8F8F8;
		border-radius: 24rpx;
		padding: 32rpx 24rpx;
		margin-top: 30rpx;

		.complant_title {
			font-weight: 500;
			font-size: 30rpx;
			color: #131313;
		}

		.complant_content {
			font-size: 26rpx;
			color: #333333;
			margin: 16rpx 0 24rpx;
			word-wrap: break-word;
		}

		image {
			width: 160rpx;
			height: 160rpx;
			border-radius: 16rpx;
			color: #ECECF4;
		}

		.complant_return {
			font-size: 26rpx;
			color: #666666;
		}
	}

	.btn {
		height: 96rpx;
		border-radius: 48rpx;
		border: 2rpx solid #999999;
		margin-top: 48rpx;

		view {
			image {
				width: 48rpx;
				height: 48rpx;
				margin-right: 24rpx;
			}

			text {
				font-weight: 600;
				font-size: 32rpx;
				color: #131313;
			}
		}
	}
</style>